<?php
	// 验证用户是否登录
	require_once 'session-check.php';
	$user = $_SESSION['login_user'];
	/**
		管理员操作post的各种处理
	 */
	require_once '../util/dbconnection.php';
	require_once '../util/error.php';
	require_once '../util/public.php';

	$action = $_GET['action'];
	$id = $_GET['id'];
	
	connect_db();
	
	if( $action == "del" ){
		$flag = del_post_by_id( $id );
		if( $flag == false )
			site_die("删除评论失败");
	}else if( $action == "restore" ){
		$flag = restore_post_by_id( $id );
		if( $flag == false )
			site_die("恢复评论失败");
	}else if( $action == "destroy" ){
		$flag = destroy_post_by_id( $id );
		if( $flag == false )
			site_die("彻底删除评论失败");
	}else{
		site_die("错误的请求");
	}
	
	close_db();
	
	site_redirct("post-admin.php");
?>